#pragma once

#include "google/protobuf/stubs/common.h"

#include <boost/asio/buffer.hpp>
#include <boost/asio/streambuf.hpp>

#include <memory>

namespace AlgoTrading
{
	namespace ConnectionLibrary
	{
		class OutputMessageBufferHolder
		{
			public:
				OutputMessageBufferHolder();
				::google::protobuf::uint32* GetMessageLength();
				boost::asio::const_buffer GetMessageBuffer();
				std::ostream& GetOutputStream();
				void ParseMessageLength();
			private:
				std::auto_ptr<boost::asio::streambuf> streamBuf;
				std::auto_ptr<std::ostream> stream;
				std::auto_ptr<::google::protobuf::uint32> messageLength;
		};

		typedef std::tr1::shared_ptr<OutputMessageBufferHolder> OutputMessageBufferHolderPtr;
	}
}